home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / gfx / show / svoUtah22.lha / svoUtahRLE / source / URT / lib / rle_rawrow.c < prev    next >
C/C++ Source or Header  |  1990-08-02  |  2KB  |  79 lines

  1. /* 
  2.  * rle_rawrow.c - Convert RLE "raw" input to "row" input.
  3.  * 
  4.  * Author:    Spencer W. Thomas
  5.  *         EECS Dept.
  6.  *         University of Michigan
  7.  * Date:    Mon Jun 18 1990
  8.  * Copyright (c) 1990, University of Michigan
  9.  */
  10.  
  11. #include <rle.h>
  12. #include <rle_raw.h>
  13. #ifdef USE_STDLIB_H
  14. #include <stdlib.h>
  15. #endif /* USE_STDLIB_H */
  16.  
  17. /*****************************************************************
  18.  * TAG( rle_rawtorow )
  19.  * 
  20.  * Convert a "raw" scanline to a row format.
  21.  * Inputs:
  22.  *     the_hdr:    RLE header describing the image.
  23.  *     raw:        Pointer to pointers to vectors of "raw" data.
  24.  *     nraw:        Pointer to vector of lengths of raw data vectors.
  25.  * Outputs:
  26.  *     outrows:    Pointer to pointers to scanline data for
  27.  *             this scanline.
  28.  * Algorithm:
  29.  *     Interpret successive "op codes", filling in scanline array.
  30.  *     Scanline between xmin and xmax is prefilled with background
  31.  *     color, if one is given.
  32.  */
  33. void    
  34. rle_rawtorow(the_hdr, raw, nraw, outrows)
  35. rle_hdr * the_hdr;
  36. rle_op ** raw;
  37. int * nraw;
  38. rle_pixel ** outrows;
  39. {
  40.     register int i, j;
  41.     register rle_pixel * outptr;
  42.     int chan;
  43.     
  44.     for (chan = -the_hdr->alpha; chan < the_hdr->ncolors; chan++)
  45.     if ( RLE_BIT( *the_hdr, chan ) )
  46.     {
  47.         if ( chan >= 0 && the_hdr->background == 2 && the_hdr->bg_color &&
  48.          the_hdr->bg_color[chan] != 0 )
  49.         {
  50.         j = the_hdr->bg_color[chan];
  51.         for ( i = the_hdr->xmin,
  52.               outptr = &outrows[chan][the_hdr->xmin];
  53.               i <= the_hdr->xmax;
  54.               i++, outptr++ )
  55.             *outptr = j;
  56.         }
  57.         else
  58.         bzero( &outrows[chan][the_hdr->xmin],
  59.                the_hdr->xmax - the_hdr->xmin + 1 );
  60.  
  61.         for( i = 0; i < nraw[chan]; i++ )
  62.         {
  63.         outptr = &(outrows[chan][raw[chan][i].xloc]);
  64.         switch (raw[chan][i].opcode)
  65.         {
  66.         case RByteDataOp:
  67.             bcopy( raw[chan][i].u.pixels, outptr,
  68.                raw[chan][i].length );
  69.             break;
  70.  
  71.         case RRunDataOp:
  72.             for ( j = raw[chan][i].length; j > 0; j--)
  73.             *(outptr++) = (rle_pixel) raw[chan][i].u.run_val;
  74.             break;
  75.         }
  76.         }
  77.     }
  78. }
  79.